﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using MovieRental.Entities;

namespace MovieRental.EfRepositoryLibrary.Mappers
{
    public class TemporaryDiscountMapper 
        : BaseMapper<TemporaryDiscountInfo, Guid, TemporaryDiscount, Discount, MovieRentalEntitiesContainer>
    {
        public override void Convert(TemporaryDiscountInfo entity, TemporaryDiscount model)
        {
            model.Id = entity.Id;
            model.Value = entity.Value;
            model.ValidUntil = entity.ValidUntil;
        }

        public override void ConvertBack(TemporaryDiscount model, TemporaryDiscountInfo entity)
        {
            entity.Id = model.Id;
            entity.ValidUntil = model.ValidUntil;
            entity.Value = model.Value;
        }

        public override Guid SelectKey(TemporaryDiscount model)
        {
            return model.Id;
        }

        public override Guid SelectKey(TemporaryDiscountInfo entity)
        {
            return entity.Id;
        }

        public override ObjectSet<Discount> SelectObjectSet(MovieRentalEntitiesContainer context)
        {
            return context.Discounts;
        }
    }
}
